const api = require('../../utils/api.js');
const app = getApp();

Page({
  data: {
    isShow: false,
    goods_type: '',
    goods_name: '',
    content: '',
  },
  getgoodstyle(e) {
    let { value } = e.detail;
    let { name } = e.currentTarget.dataset;
    this.data[name] = value;
    let { goods_type, goods_name, content, isShow } = this.data;
    if (goods_type.trim() && goods_name.trim() && content.trim()) {
      isShow = true;
    } else {
      isShow = false;
    }
    this.setData({
      isShow,
    })
  },
  submitFeedBack() {
    let { goods_type, goods_name, content } = this.data;
    app.ws_micro_shoprequest({
      url: api.default.feedback,
      data: {
        goods_type,
        goods_name,
        content,
      },
      method: 'POST',
      success: res => {
        if (res.code === 0) {
          wx.showToast({
            title: '提交成功',
            icon: 'none',
          });
          this.setData({
            isShow: false,
          })
          setTimeout(function() {
            wx.navigateBack();
          }, 500);
        } else {
          wx.showToast({
            title: '提交失败',
            icon: 'none',
          });
        }
      },
    });
  },
});
